// @Date         2021-11-05
// @Author       Aaron Zhang
// @Description   路径参数
// @FileName      iparam.go   

package gin

import "strconv"

type IParam interface {
	DefaultParamString(string, string) string
	DefaultParamInt(string, int) int
}

func (c *Context) DefaultParamString(key string, def string) string {
	val := c.Param(key)
	if val == "" {
		val = def
	}
	return val
}

func (c *Context) DefaultParamInt(key string, def int) int {
	val := c.Param(key)
	if val != "" {
		intVal, _ := strconv.Atoi(val)
		return intVal
	}
	return def
}
